﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;

namespace NSATBPortal
{
    public partial class TestSetHome : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void DefTestSetGrid_RowEditing(object sender, GridViewEditEventArgs e)
        {
            e.Cancel = true;

            int iIndex = e.NewEditIndex;

            string sRecID = DefTestSetGrid.DataKeys[iIndex].Value.ToString();

            Response.Redirect("TestSetCreate.aspx?Op=Edit&ID=" + sRecID.Trim());
        }

        protected void DefTestSetGrid_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            e.Cancel = true;

            int iIndex = DefTestSetGrid.SelectedIndex;
            string sRecID = DefTestSetGrid.DataKeys[iIndex].Value.ToString();
        }

        protected void DefTestSetGrid_Init(object sender, EventArgs e)
        {
            using (ATBSchemaDB objATBDB = new ATBSchemaDB())
            {
                DataTable dtResults = objATBDB.GetDefTestSetList();
                DefTestSetGrid.DataSource = dtResults;
                DefTestSetGrid.DataBind();
            }

        }

        protected void DefTestSetGrid_RowInsert(object sender, GridViewCommandEventArgs e)
        {
            int iIndex = Convert.ToInt32(e.CommandArgument);
            string sRecID = DefTestSetGrid.DataKeys[iIndex].Value.ToString();
            string sRecName = DefTestSetGrid.Rows[iIndex].Cells[3].Text;
            if(e.CommandName == "Select")
            {
                Response.Redirect("TestSetEditAssignments.aspx?ID=" + sRecID.Trim() + "&Name=" + Server.UrlEncode(sRecName));
                e.Handled = true;
                return;
            }
            if (e.CommandName == "New")
            {
                Response.Redirect("TestSetEditOrder.aspx?ID=" + sRecID.Trim() + "&Name=" + Server.UrlEncode(sRecName));
                e.Handled = true;
                return;
            }
        }

    }
}